package com.ruoyi.nucleicacid.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.nucleicacid.domain.UserRegister;
import com.ruoyi.nucleicacid.service.IuserRegisterService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 核酸注册Controller
 * 
 * @author ruoyi
 * @date 2022-10-06
 */
@RestController
@RequestMapping("/useRegister")
public class userRegisterController extends BaseController
{
    @Autowired
    private IuserRegisterService userRegisterService;

    /**
     * 查询核酸注册列表
     */
    @RequiresPermissions("nucleicacid:useRegister:list")
    @GetMapping("/list")
    public TableDataInfo list(UserRegister userRegister)
    {
        startPage();
        List<UserRegister> list = userRegisterService.selectuserRegisterList(userRegister);
        return getDataTable(list);
    }

    /**
     * 导出核酸注册列表
     */
    @RequiresPermissions("nucleicacid:useRegister:export")
    @Log(title = "核酸注册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserRegister userRegister)
    {
        List<UserRegister> list = userRegisterService.selectuserRegisterList(userRegister);
        ExcelUtil<UserRegister> util = new ExcelUtil<UserRegister>(UserRegister.class);
        util.exportExcel(response, list, "核酸注册数据");
    }

    /**
     * 获取核酸注册详细信息
     */
    @RequiresPermissions("nucleicacid:useRegister:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(userRegisterService.selectuserRegisterById(id));
    }

    /**
     * 新增核酸注册
     */
    @RequiresPermissions("nucleicacid:useRegister:add")
    @Log(title = "核酸注册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserRegister userRegister)
    {
        return toAjax(userRegisterService.insertuserRegister(userRegister));
    }

    /**
     * 修改核酸注册
     */
    @RequiresPermissions("nucleicacid:useRegister:edit")
    @Log(title = "核酸注册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserRegister userRegister)
    {
        return toAjax(userRegisterService.updateuserRegister(userRegister));
    }

    /**
     * 删除核酸注册
     */
    @RequiresPermissions("nucleicacid:useRegister:remove")
    @Log(title = "核酸注册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userRegisterService.deleteuserRegisterByIds(ids));
    }
}
